<?php 
$rows = array(1, 2, 3, 4, 5, 6, "sum1", "max", "min", "sum2", "straight", "trilling", "full", "poker", "yamb", "sum3");
?>

<div class="yamb-help popup">
	<a class="right yamb-help-close" href="javascript:void(0);" onclick="$(this).parent().slideUp('fast')">close</a>
	<h1>Pomoć</h1>
	<div class="content"></div>
</div>

<div id="user-register-form" class="popup">
	<a class="right yamb-help-close" href="javascript:void(0);" onclick="$(this).parent().slideUp('fast')">close</a>
	<script type="text/javascript">loadElement("register", "#user-register-form");</script>
</div>

<div id="user-login-form" class="popup">
	<a class="right yamb-help-close" href="javascript:void(0);" onclick="$(this).parent().slideUp('fast')">close</a>
	<script type="text/javascript">loadElement("login", "#user-login-form");</script>
</div>

<div id="player-list" class="popup">
	<h1>Igrači dostupni za igru</h1>
	<a class="right yamb-help-close" href="javascript:void(0);" onclick="$(this).parent().slideUp('fast')">close</a>
	<input type="text" class="filter right" value="Search..." size="16" />
	<div class="content"></div>
</div>

<div class="yamb-container" style="width: 474px;">
	<?php echo $this->fetch("yamb/elements/toolbar"); ?>
	<div class="yamb-table">
		<h1 class="game-title">YAMB</h1>
		<table class="yamb">
			<tbody>
				<tr class="head">
					<td class="empty"></td>
					<?php foreach($options["games"] as $game): ?>
					<td style="background-image: url(/img/gui/column_<?php echo $game; ?>.png);" class="<?php echo $game; ?>"></td>
					<?php endforeach; ?>
					<td class="empty"></td>
				</tr>
				<?php foreach($rows as $row): ?>
					<?php $sum = preg_match('/^sum\d*$/', $row); ?>
					<tr game="<?php echo $row; ?>" class="<?php echo $sum?"sum":""; ?>">
						<td class="label"><?php echo $sum?"":$row; ?></td>
						<?php foreach($options["games"] as $game): ?>
						<td locked="0" class="<?php echo $sum?"":"field"?>" game_column="<?php echo $game; ?>" game_row="<?php echo $row; ?>"></td>
						<?php endforeach; ?>
						<?php if($sum): ?>
							<td class="total"></td>
						<?php else: ?>
							<td class="empty"></td>
						<?php endif; ?>
					</tr>
				<?php endforeach; ?>
				<tr class="sum">
					<td class="empty"></td>
					<?php foreach($options["games"] as $game): ?>
						<td class="empty"></td>
					<?php endforeach; ?>
					<td class="total yamb-total"></td>
				</tr>
			</tbody>
		</table>
		<div class="controls">
			<ul class="dices">
				<li value="0" class="dice-1"></li>
				<li value="0" class="dice-2"></li>
				<li value="0" class="dice-3"></li>
				<li value="0" class="dice-4"></li>
				<li value="0" class="dice-5"></li>
				<li value="0" class="dice-6"></li>
			</ul>
			<br clear="all">
			<a class="undo" href="javascript:void(0)" style="display: none;">undo</a>
			<div class="display">0</div>
			<input type="button" class="throw-button" value="B A C A Nj E">
			<div value="91" class="yamb-countdown">91</div>
			<div class="yamb-countdown-label">Preostalo polja:</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	var _pretraga = "Pretraga...";
	$("#player-list .filter").val(_pretraga);
	$("#player-list .filter").focus(function(){
		if(this.value == _pretraga) {
			this.value = "";
		}
	});
	$("#player-list .filter").blur(function(){
		if(this.value=="") {
			this.value = _pretraga;
		}
	});
	$("#player-list .filter").keyup(function(){
		var _this=this;
		this.timeout = setTimeout(function(){
			if(_this.value.length && _this.value!=_pretraga) {
				$("#player-list li a").each(function(){
					if($(this).html().indexOf(_this.value)>=0) {
						$(this).parent().show();
					}else{
						$(this).parent().hide();
					}
				});
			}else{
				$("#player-list li").show();
			}
		}, 1000);
	});
	$("#player-list .filter").keypress(function(){
		if(this.timeout) {
			clearTimeout(this.timeout);
		}
	});
});
</script>